<%# nested_id, allows us to remove a nested scaffold programmatically %>
<tr class="inline-adapter" id="<%= nested_id = element_row_id action: :nested %>">
  <td class="inline-adapter-cell">
<% if successful? %>
    <div class="<%= "#{params[:action]}-view" if params[:action] %> <%= "#{nested? ? nested.name : id_from_controller(params[:controller])}-view" %> view">
      <%= link_to(as_(:close), '', class: 'inline-adapter-close as_cancel', remote: true, title: as_(:close)) -%>
      <%= payload -%>
    </div>
<% end %>
    <%= javascript_tag do %>
      setTimeout(function() {
        var action_link = ActiveScaffold.ActionLink.get('<%= nested_id %>');
        if (action_link) {
          action_link.update_flash_messages('<%= escape_javascript(render('messages')) %>');
      <% unless successful? %>
          action_link.close();
          ActiveScaffold.scroll_to(action_link.scaffold(), ActiveScaffold.config.scroll_on_close == 'checkInViewport');
      <% end %>
        }
      }, 10);
    <% end %>
  </td>
</tr>
